package org.car.world.controller.shop;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.car.world.common.util.MyPlUtil;
import org.car.world.common.util.Page;
import org.car.world.core.entily.OrderTable;
import org.car.world.core.entily.PictureTable;
import org.car.world.service.PictureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author szw
 * @ClassName: MessageController
 * @Description: 通知控制器
 * @date 2019年1月12日
 */
@Controller
@RequestMapping("shop")
public class MessageController {

    @Autowired
    PictureService pictureService;


    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: mess
     * @Description: 访问通知页面
     */
    @RequestMapping("domess")
    public String mess() {
        return "shop/message";
    }


    /**
     * @param @param  form
     * @param @return 参数
     * @return Map<String   ,   Object>    返回类型
     * @throws
     * @Title: message
     * @Description: 访问我的评论
     */
    @RequestMapping("messlist")
    @ResponseBody
    public Map<String, Object> messlist(@RequestParam(value = "form", defaultValue = "1", required = false) Integer form) {
        Map<String, Object> maphash = new HashMap<String, Object>();
        List<PictureTable> piclist = new ArrayList<PictureTable>();
        Page<PictureTable> Page = new Page<PictureTable>();
        Page.setCurrentPage(form);
        Page.setPageSize(7);
        Page.setTotalRow(pictureService.count(2));
        piclist = pictureService.selectLimit(Page.getCurrentPage(), Page.getPageSize(), 2);
        if (piclist.size() > 0) {
            Page.setPageList(piclist);
        }

        maphash.put("Page", Page);
        maphash.put("Img", piclist.get(0).getInformationPicture().split(",")[0]);

        return maphash;
    }

}
